--FGO功能脚本开源 仅供娱乐学习 请勿用于出售贩卖获取非法利益！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
-------------------------------------------------------功能实现-------------------------------------------------
function SearchWrite(Search, Write, Type)
    gg.clearResults()
    gg.setVisible(false)
    gg.searchNumber(Search[1][1], Type)
    local count = gg.getResultCount()
    local result = gg.getResults(count)
    gg.clearResults()
    local data = {} 
    local base = Search[1][2] 
    
   if (count > 0) then
        for i, v in ipairs(result) do
            v.isUseful = true 
        end
        
        for k=2, #Search do
            local tmp = {}
            local offset = Search[k][2] - base 
            local num = Search[k][1] 
            
            for i, v in ipairs(result) do
                tmp[#tmp+1] = {} 
                tmp[#tmp].address = v.address + offset  
                tmp[#tmp].flags = v.flags  
            end
            
            tmp = gg.getValues(tmp) 
            
            for i, v in ipairs(tmp) do
                if ( tostring(v.value) ~= tostring(num) ) then 
                    result[i].isUseful = false 
                end
            end
        end
  
        for i, v in ipairs(result) do
            if (v.isUseful) then 
                data[#data+1] = v.address
            end
        end
        
        if (#data > 0) then
       
           local t = {}
           local base = Search[1][2]
           for i=1, #data do
               for k, w in ipairs(Write) do
                   offset = w[2] - base
                   t[#t+1] = {}
                   t[#t].address = data[i] + offset
                   t[#t].flags = Type
                   t[#t].value = w[1]
                  
                   if (w[3] == true) then
                       local item = {}
                       item[#item+1] = t[#t]
                       item[#item].freeze = true
                       gg.addListItems(item)
                   end
                  
               end
           end
           gg.setValues(t)
       
        
        else
        
            return false
        end
    else
     
        return false
    end
end

function Main_moniqi()
	menu = gg.choice({
	'【刷图】从者攻击力秒杀满NP',
	'【娱乐】全体从者技能CD无冷却',
	'【娱乐】跳过敌方攻击回合',
	'【回上一层】',
	},nil,'电脑模拟器科技')
	if menu == 1 then ModifyATK_NP_moniqi() end
	if menu == 2 then NOCD_moniqi() end
	if menu == 3 then SkipEnemyRound_moniqi() end
	if menu == 4 then Select() end
	XGCK=-1
end

function Main_shouji()
	menu = gg.choice({
	'【刷图】从者攻击力秒杀满NP',
	'【娱乐】全体从者技能CD无冷却',
	'【娱乐】跳过敌方攻击回合',
	'【刷图】选卡后敌方全体消失',
	'【回上一层】'
	},nil,'安卓手机版科技')
	if menu == 1 then ModifyATK_NP_shouji() end
	if menu == 2 then NOCD_shouji() end
	if menu == 3 then SkipEnemyRound_shouji() end
	if menu == 4 then DisappearSelect_shouji() end
	if menu == 5 then Select() end
	XGCK=-1
end

function Select()
	menu = gg.choice({
	'【安卓手机版科技】',
	'【电脑模拟器科技】',
	'【退出】'
	},nil,'')

	if menu == 1 then Main_shouji() end
	if menu == 2 then Main_moniqi() end
	if menu == 3 then os.exit() end
	
	XGCK=-1
end

-----------------------------------------------------------模拟器版----------------------------------------------

function ModifyATK_moniqi() 
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 444444, 0x0},
	{0, 220},
	{10000, 236},
	}
	local tb2 = {
	{1000000, 192},
	}
	SearchWrite(tb1, tb2, dataType) 
end

function ModifyNP_moniqi() 
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 444444, 0},
	{0, 220},
	{10000, 236},
	}
	local tb2 = {
	{10000, 228},
	}
	SearchWrite(tb1, tb2, dataType)  
end

function ModifyATK_NP_moniqi() 
	ModifyATK_moniqi()
	ModifyNP_moniqi() 
	gg.clearResults()
	gg.sleep(4000)
	ModifyATK_NP_moniqi()
end

function NOCD_moniqi()
	gg.toast("正在开启请稍后……………………")
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 11, 0x0}, 
	{0, 0x1C},
	{1, 0x20},
	{-1, 0x28},
	}
	local tb2 = {
	{0, 0x18,(true)},
	}
	SearchWrite(tb1, tb2, dataType) 
	gg.toast("开启成功！！")
	os.exit()
end

function SkipEnemyRound_moniqi() 
	gg.toast("正在开启请稍后……………………")
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 444444, 0x0}, 
	{10000, 104},  
	}
	local tb2 = {
	{0, 84},
	}
	SearchWrite(tb1, tb2, dataType)
	gg.toast("开启成功！！")
end
------------------------------------------------------------手机版-----------------------------------------------
function ModifyATK_shouji() 
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 444444, 0},
	{0, 0x54},  
	{10000, 0x68},
	}
	local tb2 = {
	{1000000, 0x40},
	}
	SearchWrite(tb1, tb2, dataType) 
end

function ModifyNP_shouji() 
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 444444, 0x0}, 
	{0, 0x54},
	{10000, 0x68}, 
	}
	local tb2 = {
	{10000, 0x60},
	}
	SearchWrite(tb1, tb2, dataType)  
end

function ModifyATK_NP_shouji() 
	ModifyATK_shouji()
	ModifyNP_shouji() 
	gg.clearResults()
	gg.sleep(4000)
	ModifyATK_NP_shouji()
end

function NOCD_shouji()
	gg.toast("正在开启请稍后……………………")
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 11, 0x0}, 
	{0, 0x1C},
	{1, 0x20},
	{-1, 0x28},
	}
	local tb2 = {
	{0, 0x18,(true)},
	}
	SearchWrite(tb1, tb2, dataType) 
	gg.toast("开启成功！！")
	os.exit()
end

function SkipEnemyRound_shouji() 
	gg.toast("正在开启请稍后……………………")
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 444444, 0x0}, 
	{10000, 0x94},  
	}
	local tb2 = {
	{0, 0x80},
	}
	SearchWrite(tb1, tb2, dataType)
	gg.toast("开启成功！！")
end

function DisappearSelect_shouji()
	local t  = gg.alert('出现蓝色Attack按钮后，点击【开始消失】','【开始消失】','【回上一层】')
	if t == 1 then
		DisappearAchieve_shouji()
	end
	if t == 2 then
		Select()
	end
end

function DisappearAchieve_shouji()
	gg.clearResults()
	gg.setRanges(gg.REGION_ANONYMOUS) 
	local dataType = gg.TYPE_DWORD 
	local tb1 = {  
	{ 444444, 0x0}, 
	{10000, 0x94},  
	}
	local tb2 = {
	{0, 0x78},
	}
	SearchWrite(tb1, tb2, dataType)
	gg.sleep(5000)
	gg.clearResults()
	DisappearSelect_shouji()
end


-----------------------------------------------------登录区域---------------------------------------------------
while(true)do
	if gg.isVisible(true) then
		XGCK=1
		gg.setVisible(false)
	end
		gg.clearResults()
	if XGCK==1 then
		Select()
	end
end
-----------------------------------------------------登录区域---------------------------------------------------

